/* NOTICE
 
    Jim - the Java Image Manager, copyright (c) 2005 - 2007 Grant Gardner 
 
    Jim is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Jim is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
    In addition, as a special exception, you are permitted to link this code
    with the 3rd party libraries required to compile this file and to
    distribute a linked combination including them. You must obey the
    GNU General Public License in all respects for all of the code except for
    those 3rd party libraries that are licenced under terms incompatible with the
    GNU General Public License.  
 
 
 NOTICE */

/*
 * Created by dnoakes on 27-Nov-2002 10:10:47 using IntelliJ IDEA.
 */

package au.com.lastweekend.jim.io.exif.makernote.canon;

import java.util.HashMap;
import java.util.Map;

import au.com.lastweekend.jim.io.metadata.Directory;

/**
 * 
 * 
 * 
 * @version $Id: CanonMakernoteDirectory.java,v 1.3 2006/02/20 12:21:10 ggardner Exp $
 * @author <a href="mailto:grant@lastweekend.com.au"> <Grant Gardner> </a>
 */
public class CanonMakernoteDirectory extends Directory {

    // CANON cameras have some funny bespoke fields that need further
    // processing...
    public static final int TAG_CANON_CAMERA_STATE_1 = 0x0001;
    public static final int TAG_CANON_CAMERA_STATE_2 = 0x0004;

    public static final int TAG_CANON_IMAGE_TYPE = 0x0006;
    public static final int TAG_CANON_FIRMWARE_VERSION = 0x0007;
    public static final int TAG_CANON_IMAGE_NUMBER = 0x0008;
    public static final int TAG_CANON_OWNER_NAME = 0x0009;
    public static final int TAG_CANON_SERIAL_NUMBER = 0x000C;
    public static final int TAG_CANON_UNKNOWN_1 = 0x000D;
    public static final int TAG_CANON_CUSTOM_FUNCTIONS = 0x000F;

    // These 'sub'-tag values have been created for consistency -- they don't
    // exist within the exif segment
    public static final int TAG_CANON_STATE1_MACRO_MODE = 0xC101;
    public static final int TAG_CANON_STATE1_SELF_TIMER_DELAY = 0xC102;
    public static final int TAG_CANON_STATE1_UNKNOWN_1 = 0xC103;
    public static final int TAG_CANON_STATE1_FLASH_MODE = 0xC104;
    public static final int TAG_CANON_STATE1_CONTINUOUS_DRIVE_MODE = 0xC105;
    public static final int TAG_CANON_STATE1_UNKNOWN_2 = 0xC106;
    public static final int TAG_CANON_STATE1_FOCUS_MODE_1 = 0xC107;
    public static final int TAG_CANON_STATE1_UNKNOWN_3 = 0xC108;
    public static final int TAG_CANON_STATE1_UNKNOWN_4 = 0xC109;
    public static final int TAG_CANON_STATE1_IMAGE_SIZE = 0xC10A;
    public static final int TAG_CANON_STATE1_EASY_SHOOTING_MODE = 0xC10B;
    public static final int TAG_CANON_STATE1_UNKNOWN_5 = 0xC10C;
    public static final int TAG_CANON_STATE1_CONTRAST = 0xC10D;
    public static final int TAG_CANON_STATE1_SATURATION = 0xC10E;
    public static final int TAG_CANON_STATE1_SHARPNESS = 0xC10F;
    public static final int TAG_CANON_STATE1_ISO = 0xC110;
    public static final int TAG_CANON_STATE1_METERING_MODE = 0xC111;
    public static final int TAG_CANON_STATE1_UNKNOWN_6 = 0xC112;
    public static final int TAG_CANON_STATE1_AF_POINT_SELECTED = 0xC113;
    public static final int TAG_CANON_STATE1_EXPOSURE_MODE = 0xC114;
    public static final int TAG_CANON_STATE1_UNKNOWN_7 = 0xC115;
    public static final int TAG_CANON_STATE1_UNKNOWN_8 = 0xC116;
    public static final int TAG_CANON_STATE1_LONG_FOCAL_LENGTH = 0xC117;
    public static final int TAG_CANON_STATE1_SHORT_FOCAL_LENGTH = 0xC118;
    public static final int TAG_CANON_STATE1_FOCAL_UNITS_PER_MM = 0xC119;
    public static final int TAG_CANON_STATE1_UNKNOWN_9 = 0xC11A;
    public static final int TAG_CANON_STATE1_UNKNOWN_10 = 0xC11B;
    public static final int TAG_CANON_STATE1_UNKNOWN_11 = 0xC11C;
    public static final int TAG_CANON_STATE1_FLASH_DETAILS = 0xC11D;
    public static final int TAG_CANON_STATE1_UNKNOWN_12 = 0xC11E;
    public static final int TAG_CANON_STATE1_UNKNOWN_13 = 0xC11F;
    public static final int TAG_CANON_STATE1_FOCUS_MODE_2 = 0xC120;

    public static final int TAG_CANON_STATE2_WHITE_BALANCE = 0xC207;
    public static final int TAG_CANON_STATE2_SEQUENCE_NUMBER = 0xC209;
    public static final int TAG_CANON_STATE2_AF_POINT_USED = 0xC20E;
    public static final int TAG_CANON_STATE2_FLASH_BIAS = 0xC20F;
    public static final int TAG_CANON_STATE2_SUBJECT_DISTANCE = 0xC213;

    // 9 A B C D E F 10 11 12 13
    // 9 10 11 12 13 14 15 16 17 18 19
    protected static final HashMap<Integer, String> TAG_NAME_MAP = new HashMap<Integer, String>();

    static {
        TAG_NAME_MAP.put((TAG_CANON_FIRMWARE_VERSION), "Firmware Version");
        TAG_NAME_MAP.put((TAG_CANON_IMAGE_NUMBER), "Image Number");
        TAG_NAME_MAP.put((TAG_CANON_IMAGE_TYPE), "Image Type");
        TAG_NAME_MAP.put((TAG_CANON_OWNER_NAME), "Owner Name");
        TAG_NAME_MAP.put((TAG_CANON_UNKNOWN_1), "Makernote Unknown 1");
        TAG_NAME_MAP.put((TAG_CANON_CUSTOM_FUNCTIONS), "Custom Functions");
        TAG_NAME_MAP.put((TAG_CANON_SERIAL_NUMBER), "Camera Serial Number");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_AF_POINT_SELECTED), "AF Point Selected");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_CONTINUOUS_DRIVE_MODE), "Continuous Drive Mode");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_CONTRAST), "Contrast");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_EASY_SHOOTING_MODE), "Easy Shooting Mode");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_EXPOSURE_MODE), "Exposure Mode");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_FLASH_DETAILS), "Flash Details");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_FLASH_MODE), "Flash Mode");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_FOCAL_UNITS_PER_MM), "Focal Units per mm");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_FOCUS_MODE_1), "Focus Mode");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_FOCUS_MODE_2), "Focus Mode");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_IMAGE_SIZE), "Image Size");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_ISO), "Iso");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_LONG_FOCAL_LENGTH), "Long Focal Length");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_MACRO_MODE), "Macro Mode");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_METERING_MODE), "Metering Mode");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_SATURATION), "Saturation");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_SELF_TIMER_DELAY), "Self Timer Delay");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_SHARPNESS), "Sharpness");
        TAG_NAME_MAP.put((TAG_CANON_STATE1_SHORT_FOCAL_LENGTH), "Short Focal Length");
        /*
         * tagNameMap.put((TAG_CANON_STATE1_UNKNOWN_1), "Unknown Camera State 1"); tagNameMap.put(new
         * Integer(TAG_CANON_STATE1_UNKNOWN_2), "Unknown Camera State 2"); tagNameMap.put((TAG_CANON_STATE1_UNKNOWN_3), "Unknown
         * Camera State 3"); tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_4), "Unknown Camera State 4");
         * tagNameMap.put((TAG_CANON_STATE1_UNKNOWN_5), "Unknown Camera State 5"); tagNameMap.put(new
         * Integer(TAG_CANON_STATE1_UNKNOWN_6), "Unknown Camera State 6"); tagNameMap.put((TAG_CANON_STATE1_UNKNOWN_7), "Unknown
         * Camera State 7"); tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_8), "Unknown Camera State 8");
         * tagNameMap.put((TAG_CANON_STATE1_UNKNOWN_9), "Unknown Camera State 9"); tagNameMap.put(new
         * Integer(TAG_CANON_STATE1_UNKNOWN_10), "Unknown Camera State 10"); tagNameMap.put((TAG_CANON_STATE1_UNKNOWN_11), "Unknown
         * Camera State 11"); tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_12), "Unknown Camera State 12");
         * tagNameMap.put((TAG_CANON_STATE1_UNKNOWN_13), "Unknown Camera State 13");
         */

        TAG_NAME_MAP.put((TAG_CANON_STATE2_WHITE_BALANCE), "White Balance");
        TAG_NAME_MAP.put((TAG_CANON_STATE2_SEQUENCE_NUMBER), "Sequence Number");
        TAG_NAME_MAP.put((TAG_CANON_STATE2_AF_POINT_USED), "AF Point Used");
        TAG_NAME_MAP.put((TAG_CANON_STATE2_FLASH_BIAS), "Flash Bias");
        TAG_NAME_MAP.put((TAG_CANON_STATE2_SUBJECT_DISTANCE), "Subject Distance");
    }

    public CanonMakernoteDirectory(Directory parent) {

        super(parent);
        this.setDescriptor(new CanonMakernoteDescriptor(this));
    }

    @Override
    public String getName() {

        return "Canon Makernote";
    }

    @Override
    protected Map<Integer, String> getTagNameMap() {

        return TAG_NAME_MAP;
    }

}